package com.dididoctor.doctor.Activity.Usercentre.MyPurse.CollectionMethods;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.dididoctor.doctor.Dialog.adapter.BaseDialog;
import com.dididoctor.doctor.R;


public class MyPurseEdittextDialog extends BaseDialog implements TextWatcher {
    private Context context;
    private EditText ed_incomebalance;
    private TextView tv_accountbalance, mTvCancel, mTvConfirm;
    private double cashNum = 0.0;
    private String curNum = "";

    public MyPurseEdittextDialog(Context context, String num, String curNum) {
        super(context);
        this.context = context;
        cashNum = Double.parseDouble(num);
        this.curNum = curNum;
        setContentView(R.layout.dialog_purse);

        initview();

    }

    private void initview() {

        ed_incomebalance = (EditText) findViewById(R.id.ed_incomebalance);
        ed_incomebalance.addTextChangedListener(this);
        tv_accountbalance = (TextView) findViewById(R.id.tv_accountbalance);

        mTvCancel = (TextView) findViewById(R.id.tv_cancel);
        mTvCancel.setOnClickListener(this);
        mTvConfirm = (TextView) findViewById(R.id.tv_confirm);
        mTvConfirm.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_confirm:
//                Intent intent = new Intent(context,);

                break;
            case R.id.tv_cancel:
                dismiss();
                break;
            default:
                break;
        }
        super.onClick(v);
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        double input = Double.parseDouble(s.toString());
        if (input - cashNum < 0) {
            mTvConfirm.setClickable(false);
        } else {
            mTvConfirm.setClickable(true);
        }
    }

    @Override
    public void afterTextChanged(Editable s) {

    }
}
